





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.auto_scheduler &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../search.html" />
    <link rel="next" title="tvm.rpc" href="rpc.html" />
    <link rel="prev" title="tvm.autotvm" href="autotvm.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html">
          

          
            
            <img src="../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.auto_scheduler</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../_sources/reference/api/python/auto_scheduler.rst.txt" rel="nofollow"> <img src="../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.auto_scheduler">
<span id="tvm-auto-scheduler"></span><h1>tvm.auto_scheduler<a class="headerlink" href="#module-tvm.auto_scheduler" title="永久链接至标题">¶</a></h1>
<p>TVM 自动调度器（Auto-scheduler）的命名空间。</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG" title="tvm.auto_scheduler.ComputeDAG"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ComputeDAG</span></code></a>(compute_or_sche)</p></td>
<td><p>自动调度器（auto-sheduler）的计算图和相关程序分析。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.LayoutRewriteOption" title="tvm.auto_scheduler.LayoutRewriteOption"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LayoutRewriteOption</span></code></a>()</p></td>
<td><p>使用布局重写的选项</p></td>
</tr>
<tr class="row-odd"><td><p>:obj:<a href="#id1"><span class="problematic" id="id2">`</span></a>RandomModel &lt;tvm.auto_scheduler.RandomModel&gt;</p></td>
<td><p>一个对所有输入都会返回随机预测结果的模型</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel" title="tvm.auto_scheduler.XGBModel"><code class="xref py py-obj docutils literal notranslate"><span class="pre">XGBModel</span></code></a>([verbose_eval, num_warmup_sample, …])</p></td>
<td><p>训练 XGBoost 模型来预测程序的标准吞吐量。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.DispatchContext" title="tvm.auto_scheduler.DispatchContext"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DispatchContext</span></code></a>()</p></td>
<td><p>Base class of dispatch context.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ApplyHistoryBest" title="tvm.auto_scheduler.ApplyHistoryBest"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ApplyHistoryBest</span></code></a>(records[, n_lines, …])</p></td>
<td><p>Apply the history best config</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ApplyHistoryBestOrSample" title="tvm.auto_scheduler.ApplyHistoryBestOrSample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ApplyHistoryBestOrSample</span></code></a>(records[, …])</p></td>
<td><p>Apply the history best config, or sample a valid schedule if no config is found.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.MeasureInput"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MeasureInput</span></code></a>(task, state)</p></td>
<td><p>保存一次测量的输入数据</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.MeasureResult" title="tvm.auto_scheduler.MeasureResult"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MeasureResult</span></code></a>(costs, error_no, error_msg, …)</p></td>
<td><p>保存一次测量的结果</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.LocalBuilder" title="tvm.auto_scheduler.LocalBuilder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LocalBuilder</span></code></a>([timeout, n_parallel, build_func])</p></td>
<td><p>LocalBuilder 使用本地 CPU 核心来构建并行程序。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.LocalRunner" title="tvm.auto_scheduler.LocalRunner"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LocalRunner</span></code></a>([timeout, number, repeat, …])</p></td>
<td><p>使用本地 CPU/GPU 测量程序消耗时间的 LocalRunner</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.RPCRunner" title="tvm.auto_scheduler.RPCRunner"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RPCRunner</span></code></a>(key, host, port[, priority, …])</p></td>
<td><p>使用 RPC 控制远程设备测量程序消耗时间的 RPCRunner</p></td>
</tr>
<tr class="row-odd"><td><p>LocalRPCMeasureContext([priority, …])</p></td>
<td><p>A context wrapper for running RPCRunner locally.</p></td>
</tr>
<tr class="row-even"><td><p>RecordToFile(filename)</p></td>
<td><p>A measurement callback that writes measurement records into a file.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.RecordReader" title="tvm.auto_scheduler.RecordReader"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RecordReader</span></code></a>(filename)</p></td>
<td><p>JSON 日志文件的读取器。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SearchTask</span></code></a>([func, args, compute_dag, …])</p></td>
<td><p>The computation information and hardware parameters for a schedule search task.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.TuningOptions" title="tvm.auto_scheduler.TuningOptions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TuningOptions</span></code></a>([num_measure_trials, …])</p></td>
<td><p>This controls the options of performance tuning.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.HardwareParams" title="tvm.auto_scheduler.HardwareParams"><code class="xref py py-obj docutils literal notranslate"><span class="pre">HardwareParams</span></code></a>([num_cores, …])</p></td>
<td><p>The parameters of target hardware used to guide the search policy.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.EmptyPolicy" title="tvm.auto_scheduler.EmptyPolicy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">EmptyPolicy</span></code></a>(task[, init_search_callbacks])</p></td>
<td><p>A simple example of the search policy which always returns the initial naive schedule (state).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SketchPolicy" title="tvm.auto_scheduler.SketchPolicy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SketchPolicy</span></code></a>(task[, program_cost_model, …])</p></td>
<td><p>The search policy that searches in a hierarchical search space defined by sketches.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.PreloadMeasuredStates" title="tvm.auto_scheduler.PreloadMeasuredStates"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PreloadMeasuredStates</span></code></a>(filename)</p></td>
<td><p>A SearchCallback to load measured states from the log file for a search policy.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.PreloadCustomSketchRule" title="tvm.auto_scheduler.PreloadCustomSketchRule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PreloadCustomSketchRule</span></code></a>(meet_condition_func, …)</p></td>
<td><p>A SearchCallback for SketchSearchPolicy that allows users to add custom sketch rule.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.TaskScheduler" title="tvm.auto_scheduler.TaskScheduler"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TaskScheduler</span></code></a>(tasks[, task_weights, …])</p></td>
<td><p>Allocate the time resources when tuning multiple tasks together.</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.get_shape_from_rewritten_layout" title="tvm.auto_scheduler.get_shape_from_rewritten_layout"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_shape_from_rewritten_layout</span></code></a>(…)</p></td>
<td><p>Get the orginal shape from a rewritten layout string.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.register_task_input_check_func" title="tvm.auto_scheduler.register_task_input_check_func"><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_task_input_check_func</span></code></a>(func_name[, …])</p></td>
<td><p>注册一个检查输入缓冲区映射的函数</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.load_best_record" title="tvm.auto_scheduler.load_best_record"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_best_record</span></code></a>(filename[, workload_key, …])</p></td>
<td><p>Return the best measurement pair form a log file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.load_records" title="tvm.auto_scheduler.load_records"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_records</span></code></a>(filename)</p></td>
<td><p>Load measurement records from a file.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.save_records" title="tvm.auto_scheduler.save_records"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save_records</span></code></a>(filename, inputs, results)</p></td>
<td><p>Append measure records to file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.extract_tasks" title="tvm.auto_scheduler.extract_tasks"><code class="xref py py-obj docutils literal notranslate"><span class="pre">extract_tasks</span></code></a>(mod, params, target[, …])</p></td>
<td><p>Extract tuning tasks from a relay program.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.remove_index_check" title="tvm.auto_scheduler.remove_index_check"><code class="xref py py-obj docutils literal notranslate"><span class="pre">remove_index_check</span></code></a>(tensor)</p></td>
<td><p>Remove the safety check in the indexing function for a tensor.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.rewrite_compute_body" title="tvm.auto_scheduler.rewrite_compute_body"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rewrite_compute_body</span></code></a>(compute_tensor, new_layout)</p></td>
<td><p>Rewrite the body of a ComputeOp according to a new layout of a placeholder</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.is_auto_scheduler_enabled" title="tvm.auto_scheduler.is_auto_scheduler_enabled"><code class="xref py py-obj docutils literal notranslate"><span class="pre">is_auto_scheduler_enabled</span></code></a>()</p></td>
<td><p>Return whether the auto-scheduler is enabled.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.create_task" title="tvm.auto_scheduler.create_task"><code class="xref py py-obj docutils literal notranslate"><span class="pre">create_task</span></code></a>(func, args, target[, …])</p></td>
<td><p>THIS API IS DEPRECATED.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.auto_schedule" title="tvm.auto_scheduler.auto_schedule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">auto_schedule</span></code></a>(task[, search_policy, …])</p></td>
<td><p>THIS API IS DEPRECATED.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.register_workload" title="tvm.auto_scheduler.register_workload"><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_workload</span></code></a>(func_name[, f, override])</p></td>
<td><p>Register a function that generates a certain workload.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.make_workload_key" title="tvm.auto_scheduler.make_workload_key"><code class="xref py py-obj docutils literal notranslate"><span class="pre">make_workload_key</span></code></a>(func, args)</p></td>
<td><p>Make a workload key by function and arguments.</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">ComputeDAG</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">compute_or_sche</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG" title="永久链接至目标">¶</a></dt>
<dd><p>自动调度器（auto-sheduler）的计算图和相关程序分析。</p>
<p>We convert a compute declaration described by <cite>tvm.compute</cite> (could be a single operator or a
subgraph) to a ComputeDAG. It keeps the input/output tensors, all operations in the DAG, and
some static analysis results for the DAG (e.g. the total float operation count,
consumer/producer relations of operations, whether an operation stage should
be tiled/compute inlined).
These analyses can help the search policy to make decisions during the search.
ComputeDAG is also responsible for the interaction between auto-scheduler’s <cite>LoopState</cite> and
TVM schedule (e.g. applying the <cite>LoopState</cite> transform steps to a TVM schedule, providing
<cite>LoopState</cite> with extra information got from TVM schedule).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>compute</strong> (<em>Union</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="te.html#tvm.te.Tensor" title="tvm.te.Tensor"><em>Tensor</em></a><em>]</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="te.html#tvm.te.Schedule" title="tvm.te.Schedule"><em>tvm.te.Schedule</em></a><em>]</em>) – Input/output tensors or workload key for a compute declaration.</p>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG.get_init_state" title="tvm.auto_scheduler.ComputeDAG.get_init_state"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_init_state</span></code></a>()</p></td>
<td><p>Get the init state of this ComputeDAG.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG.apply_steps_from_state" title="tvm.auto_scheduler.ComputeDAG.apply_steps_from_state"><code class="xref py py-obj docutils literal notranslate"><span class="pre">apply_steps_from_state</span></code></a>(state[, layout_rewrite])</p></td>
<td><p>Apply the history transform steps from a State to get a TVM schedule.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG.print_python_code_from_state" title="tvm.auto_scheduler.ComputeDAG.print_python_code_from_state"><code class="xref py py-obj docutils literal notranslate"><span class="pre">print_python_code_from_state</span></code></a>(state)</p></td>
<td><p>Print transform steps in the history of a State as TVM’s python schedule code.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG.infer_bound_from_state" title="tvm.auto_scheduler.ComputeDAG.infer_bound_from_state"><code class="xref py py-obj docutils literal notranslate"><span class="pre">infer_bound_from_state</span></code></a>(state)</p></td>
<td><p>Infer and fill the bound of all iterators of a state.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG.rewrite_layout_from_state" title="tvm.auto_scheduler.ComputeDAG.rewrite_layout_from_state"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rewrite_layout_from_state</span></code></a>(state)</p></td>
<td><p>Rewrite the layout of the DAG according to the history transform steps of a state.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG.workload_key" title="tvm.auto_scheduler.ComputeDAG.workload_key"><code class="xref py py-obj docutils literal notranslate"><span class="pre">workload_key</span></code></a>()</p></td>
<td><p>Return the workload key of this compute DAG.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG.get_init_state">
<span class="sig-name descname"><span class="pre">get_init_state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG.get_init_state" title="永久链接至目标">¶</a></dt>
<dd><p>Get the init state of this ComputeDAG.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>state</strong> – The initial State without any transform steps.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>State</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG.apply_steps_from_state">
<span class="sig-name descname"><span class="pre">apply_steps_from_state</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">state</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout_rewrite</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG.apply_steps_from_state" title="永久链接至目标">¶</a></dt>
<dd><p>Apply the history transform steps from a State to get a TVM schedule.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>state</strong> (<em>Union</em><em>[</em><em>State</em><em>, </em><em>StateObject</em><em>]</em>) – The state from which we get transform steps.</p></li>
<li><p><strong>layout_rewrite</strong> (<em>LayoutRewriteOption = NoRewrite</em>) – Rewrite the layout of placeholders specified by “layout_free_placeholders” attr
to make it most friendly for the generated schedule to read from.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p></p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>A <cite>te.schedule</cite> and the a list of <cite>te.Tensor</cite> to be used in <cite>tvm.lower</cite> or <cite>tvm.build</cite>.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG.print_python_code_from_state">
<span class="sig-name descname"><span class="pre">print_python_code_from_state</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG.print_python_code_from_state" title="永久链接至目标">¶</a></dt>
<dd><p>Print transform steps in the history of a State as TVM’s python schedule code.</p>
<p>This is used to print transformation steps for debugging.
Use <cite>apply_steps_from_state</cite> if you want to get a schedule for code generation.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>state</strong> (<em>Union</em><em>[</em><em>State</em><em>, </em><em>StateObject</em><em>]</em>) – The state from which we get transform steps.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>str</strong> – The Python schedule code.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Str</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG.infer_bound_from_state">
<span class="sig-name descname"><span class="pre">infer_bound_from_state</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG.infer_bound_from_state" title="永久链接至目标">¶</a></dt>
<dd><p>Infer and fill the bound of all iterators of a state.</p>
<p>The states may lose complete bound information after some transform steps
(e.g., compute_at).
We can call this function to infer and fill all the bound information.
This function calls TVM InferBound pass internally to get the bound.
The returned state of this function is guaranteed to have complete iterator extent
information.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>state</strong> (<em>Union</em><em>[</em><em>State</em><em>, </em><em>StateObject</em><em>]</em>) – The state from which we get transform steps.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>updated_state</strong> – The State with complete bound information.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>State</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG.rewrite_layout_from_state">
<span class="sig-name descname"><span class="pre">rewrite_layout_from_state</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG.rewrite_layout_from_state" title="永久链接至目标">¶</a></dt>
<dd><p>Rewrite the layout of the DAG according to the history transform steps of a state.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>state</strong> (<em>Union</em><em>[</em><em>State</em><em>, </em><em>StateObject</em><em>]</em>) – The state from which we get transform steps.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>updated_dag</strong> – The compute dag with rewritten layout.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG" title="tvm.auto_scheduler.ComputeDAG">ComputeDAG</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ComputeDAG.workload_key">
<span class="sig-name descname"><span class="pre">workload_key</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ComputeDAG.workload_key" title="永久链接至目标">¶</a></dt>
<dd><p>Return the workload key of this compute DAG.
The workload key is a JSON string from a tuple of (hash of DAG, tensor shapes…)</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>key</strong> – The workload key of this compute DAG</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.LayoutRewriteOption">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">LayoutRewriteOption</span></span><a class="headerlink" href="#tvm.auto_scheduler.LayoutRewriteOption" title="永久链接至目标">¶</a></dt>
<dd><p>使用布局重写的选项</p>
<p>The NO_REWRITE and INSERT_TRANSFORM_STAGE are expected to be used when tuning a standalone op,
and the REWRITE_FOR_PRE_TRANSFORMED is expected to be used when tuning ops inside a network.</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.LayoutRewriteOption.get_target_default" title="tvm.auto_scheduler.LayoutRewriteOption.get_target_default"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_target_default</span></code></a>(target[, …])</p></td>
<td><p>Get the default layout rewrite option for the specified target.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.LayoutRewriteOption.get_target_default">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">get_target_default</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">in_relay_integration</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.LayoutRewriteOption.get_target_default" title="永久链接至目标">¶</a></dt>
<dd><p>Get the default layout rewrite option for the specified target.
Currently we only enable layout rewrite for cpu / mali backend for now</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a>) – The compilation target.</p></li>
<li><p><strong>in_relay_integration</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – If this check is ask for relay integration.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>layout_rewrite_option</strong> – The default layout rewrite option for the specified target.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.auto_scheduler.LayoutRewriteOption" title="tvm.auto_scheduler.LayoutRewriteOption">LayoutRewriteOption</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.get_shape_from_rewritten_layout">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">get_shape_from_rewritten_layout</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rewritten_layout</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis_names</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.get_shape_from_rewritten_layout" title="永久链接至目标">¶</a></dt>
<dd><p>Get the orginal shape from a rewritten layout string.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>rewritten_layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The layout after rewrite</p></li>
<li><p><strong>axis_names</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – Specify the order of axes by names</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>shape</strong> – The original shape</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="ir.html#tvm.ir.PrimExpr" title="tvm.ir.PrimExpr">PrimExpr</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RandomModel">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">RandomModel</span></span><a class="headerlink" href="#tvm.auto_scheduler.RandomModel" title="永久链接至目标">¶</a></dt>
<dd><p>一个对所有输入都会返回随机预测结果的模型</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.RandomModel.update" title="tvm.auto_scheduler.RandomModel.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>(inputs, results)</p></td>
<td><p>Update the cost model according to new measurement results (training data).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.RandomModel.predict" title="tvm.auto_scheduler.RandomModel.predict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">predict</span></code></a>(search_task, states)</p></td>
<td><p>Predict the scores of states</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RandomModel.update">
<span class="sig-name descname"><span class="pre">update</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">results</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RandomModel.update" title="永久链接至目标">¶</a></dt>
<dd><p>Update the cost model according to new measurement results (training data).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>inputs</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.measure.MeasureInput"><em>auto_scheduler.measure.MeasureInput</em></a><em>]</em>) – The measurement inputs</p></li>
<li><p><strong>results</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.MeasureResult" title="tvm.auto_scheduler.measure.MeasureResult"><em>auto_scheduler.measure.MeasureResult</em></a><em>]</em>) – The measurement results</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RandomModel.predict">
<span class="sig-name descname"><span class="pre">predict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">search_task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">states</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RandomModel.predict" title="永久链接至目标">¶</a></dt>
<dd><p>Predict the scores of states</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>search_task</strong> (<a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a>) – The search task of states</p></li>
<li><p><strong>states</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>State</em><em>]</em>) – 输入状态</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>scores</strong> – The predicted scores for all states</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)">float</a>]</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">XGBModel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">verbose_eval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">25</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_warmup_sample</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model_file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adapative_training</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel" title="永久链接至目标">¶</a></dt>
<dd><p>Train a XGBoost model to predict the normalized throughputs of programs.
Let the normalized throughput be the score of a program (higher is better). We predict
the (approximate) score of a program = the sum of the scores of all stages in this program.
i.e. score(P) = score_s0 + score_s1 + … + score_sn,
where score_si is the score of Stage i in Program P.
We extract feature for each stage and let the xgboost predict the score for each stage.
We then sum up the predictions as the score of the whole program.
We use RMSE as the loss function.  i.e. loss(P, y) = 1/2 * (score(P) - y)^2,
where P is the program and y is the normalized throughput according to
the ground truth (measurement).
XGBoost does not support this loss function because <cite>score(P)</cite> is a sum of the prediction
of several samples, so we implemented a custom loss function and call it pack-sum-rmse.
It is called “pack-sum” because we combine several samples into a “pack” and sum up
their predictions.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>verbose_eval</strong> (<em>int = 25</em>) – Print training log every <cite>verbose_eval</cite> iterations.</p></li>
<li><p><strong>num_warmup_sample</strong> (<em>int = 100</em>) – The minimum number of samples to start to use the trained model.
If the number of samples is less than this number, the model outputs random predictions.</p></li>
<li><p><strong>seed</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – 随机种子</p></li>
<li><p><strong>model_file</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – If is not None, save model to this file after every update.</p></li>
<li><p><strong>adapative_training</strong> (<em>bool = False</em>) – Whether to use adapatie training, which reduces the training frequency when there are
too many logs.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel.update" title="tvm.auto_scheduler.XGBModel.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>(inputs, results)</p></td>
<td><p>Update the cost model according to new measurement results (training data).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel.predict" title="tvm.auto_scheduler.XGBModel.predict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">predict</span></code></a>(task, states)</p></td>
<td><p>Predict the scores of states :param search_task: The search task of states :type search_task: SearchTask :param statse: The input states :type statse: List[State]</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel.predict_stages" title="tvm.auto_scheduler.XGBModel.predict_stages"><code class="xref py py-obj docutils literal notranslate"><span class="pre">predict_stages</span></code></a>(task, states)</p></td>
<td><p>Predict the scores of all stages in states.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel.update_from_file" title="tvm.auto_scheduler.XGBModel.update_from_file"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update_from_file</span></code></a>(file_name[, n_lines])</p></td>
<td><p>Load measure records from a log file to update the cost model.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel.save" title="tvm.auto_scheduler.XGBModel.save"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save</span></code></a>(file_name)</p></td>
<td><p>Save the model to a file :param file_name: The filename :type file_name: str</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.XGBModel.load" title="tvm.auto_scheduler.XGBModel.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load</span></code></a>(file_name)</p></td>
<td><p>Load the model from a file :param file_name: The filename :type file_name: str</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel.update">
<span class="sig-name descname"><span class="pre">update</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">results</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel.update" title="永久链接至目标">¶</a></dt>
<dd><p>Update the cost model according to new measurement results (training data).
XGBoost does not support incremental training, so we re-train a new model every time.
:param inputs: The measurement inputs
:type inputs: List[MeasureInput]
:param results: The measurement results
:type results: List[MeasureResult]</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel.predict">
<span class="sig-name descname"><span class="pre">predict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">states</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel.predict" title="永久链接至目标">¶</a></dt>
<dd><p>Predict the scores of states
:param search_task: The search task of states
:type search_task: SearchTask
:param statse: The input states
:type statse: List[State]</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>scores</strong> – The predicted scores for all states</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)">float</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel.predict_stages">
<span class="sig-name descname"><span class="pre">predict_stages</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">states</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel.predict_stages" title="永久链接至目标">¶</a></dt>
<dd><p>Predict the scores of all stages in states. This is the breakdown version of <cite>predict</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>search_task</strong> (<a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a>) – The search task of states</p></li>
<li><p><strong>statse</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>State</em><em>]</em>) – 输入状态</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>scores</strong> – The predicted scores for all stages in all states in the packed format</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)">float</a>]</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>For faster data copy between c++ and python, the python part returns scores in a
single flatten array using a packed format. The c++ part then unpacks the flatten array.
The packed format is:
{</p>
<blockquote>
<div><p>float  scores[N];                 // scores[i] is the score for states[i].
int    n_stage_0;                 // the number of stages in states[0]
float  stage_scores_0[[n_stage_0] // the scores for all stages in states[0]
int    n_stage_1;                 // the number of stages in states[1]
float  stage_scores_1[n_stage_1]; // the scores for all stages in states[1]
…
int    n_stage_i;                 // the number of stages in states[i]
float  stage_scores_1[n_stage_i]; // the scores for all stages in states[i]
…  // untill i == N - 1</p>
</div></blockquote>
<p>}
To implement this format, we also store int as float, so we can store all numbers
into a single float array.</p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel.update_from_file">
<span class="sig-name descname"><span class="pre">update_from_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_lines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel.update_from_file" title="永久链接至目标">¶</a></dt>
<dd><p>Load measure records from a log file to update the cost model.
This function can be used to pre-train the cost model with history log files.
:param file_name: The filename
:type file_name: str
:param n_lines: Only load first n lines of the log file
:type n_lines: Optional[int]</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel.save">
<span class="sig-name descname"><span class="pre">save</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel.save" title="永久链接至目标">¶</a></dt>
<dd><p>Save the model to a file
:param file_name: The filename
:type file_name: str</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.XGBModel.load">
<span class="sig-name descname"><span class="pre">load</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_name</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.XGBModel.load" title="永久链接至目标">¶</a></dt>
<dd><p>Load the model from a file
:param file_name: The filename
:type file_name: str</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.DispatchContext">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">DispatchContext</span></span><a class="headerlink" href="#tvm.auto_scheduler.DispatchContext" title="永久链接至目标">¶</a></dt>
<dd><p>Base class of dispatch context.</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.DispatchContext.query" title="tvm.auto_scheduler.DispatchContext.query"><code class="xref py py-obj docutils literal notranslate"><span class="pre">query</span></code></a>(target, workload_key, has_complex_op, …)</p></td>
<td><p>Query the context to get the specific config for a workload.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.DispatchContext.update" title="tvm.auto_scheduler.DispatchContext.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>(target, workload_key, state)</p></td>
<td><p>Update the config for a workload</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.DispatchContext.query">
<span class="sig-name descname"><span class="pre">query</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">has_complex_op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.DispatchContext.query" title="永久链接至目标">¶</a></dt>
<dd><p>Query the context to get the specific config for a workload.
If this function cannot find the result inside this context, it will query the result
from the upper contexts.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>Target</em></a>) – The current target</p></li>
<li><p><strong>workload_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The workload key</p></li>
<li><p><strong>has_complex_op</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether this workload has at least one complex op.</p></li>
<li><p><strong>dag</strong> (<a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG" title="tvm.auto_scheduler.ComputeDAG"><em>ComputeDAG</em></a>) – The ComputeDAG of the workload.</p></li>
<li><p><strong>func_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The function name of this workload.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>state</strong> – The state that stores schedule configuration for the workload</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>StateObject</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.DispatchContext.update">
<span class="sig-name descname"><span class="pre">update</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.DispatchContext.update" title="永久链接至目标">¶</a></dt>
<dd><p>Update the config for a workload</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>Target</em></a>) – The current target</p></li>
<li><p><strong>workload_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The current workload_key.</p></li>
<li><p><strong>state</strong> (<em>StateObject</em>) – The state that stores schedule configuration for the workload</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ApplyHistoryBest">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">ApplyHistoryBest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">records</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_lines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_compatible</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ApplyHistoryBest" title="永久链接至目标">¶</a></dt>
<dd><p>Apply the history best config</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>records</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>iterator of</em><em> (</em><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.measure.MeasureInput"><em>auto_scheduler.measure.MeasureInput</em></a><em>,                                  </em><a class="reference internal" href="#tvm.auto_scheduler.MeasureResult" title="tvm.auto_scheduler.measure.MeasureResult"><em>auto_scheduler.measure.MeasureResult</em></a><em>)</em>) – Collection of tuning records.
If is str, then it should be the filename of a records log file.
Each row of this file is an encoded record pair. Otherwise, it is an iterator.</p></li>
<li><p><strong>n_lines</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – if it is not None, only load the first <cite>n_lines</cite> lines of log.</p></li>
<li><p><strong>include_compatible</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – When set to True, compatible records will also be considered.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ApplyHistoryBest.get_workload_entry" title="tvm.auto_scheduler.ApplyHistoryBest.get_workload_entry"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_workload_entry</span></code></a>(best_records, target_key, …)</p></td>
<td><p>Get the entry of the target key and workload key hash in the given best record map.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ApplyHistoryBest.load" title="tvm.auto_scheduler.ApplyHistoryBest.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load</span></code></a>(records[, n_lines])</p></td>
<td><p>Load records to this dispatch context</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ApplyHistoryBest.update" title="tvm.auto_scheduler.ApplyHistoryBest.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>(target, workload_key, state)</p></td>
<td><p>Update the config for a workload</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ApplyHistoryBest.get_workload_entry">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">get_workload_entry</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">best_records</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ApplyHistoryBest.get_workload_entry" title="永久链接至目标">¶</a></dt>
<dd><p>Get the entry of the target key and workload key hash in the given best record map.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>best_records</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>]</em><em>]</em>) – The best record map.</p></li>
<li><p><strong>target_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The first key to the best_records.</p></li>
<li><p><strong>workload_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The workload key that can be decoded to workload hash and args.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>entry</strong> (<em>Dict[str, Any]</em>) – The entry in best_records with target key and workload hash.</p></li>
<li><p><strong>workload_hash</strong> (<em>str</em>) – The workload hash decoded from workload_key.</p></li>
<li><p><strong>workload_args</strong> (<em>Tuple[Any, …]</em>) – The hashable tuple of workload args decoded from workload_key.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ApplyHistoryBest.load">
<span class="sig-name descname"><span class="pre">load</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">records</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_lines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ApplyHistoryBest.load" title="永久链接至目标">¶</a></dt>
<dd><p>Load records to this dispatch context</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>records</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>iterator of</em><em> (</em><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.measure.MeasureInput"><em>auto_scheduler.measure.MeasureInput</em></a><em>,                                      </em><a class="reference internal" href="#tvm.auto_scheduler.MeasureResult" title="tvm.auto_scheduler.measure.MeasureResult"><em>auto_scheduler.measure.MeasureResult</em></a><em>)</em>) – Collection of tuning records.
If is str, then it should be the filename of a records log file.
Each row of this file is an encoded record pair. Otherwise, it is an iterator.</p></li>
<li><p><strong>n_lines</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – if it is not None, only load the first <cite>n_lines</cite> lines of log</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ApplyHistoryBest.update">
<span class="sig-name descname"><span class="pre">update</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ApplyHistoryBest.update" title="永久链接至目标">¶</a></dt>
<dd><p>Update the config for a workload</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>Target</em></a>) – The current target</p></li>
<li><p><strong>workload_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The current workload_key.</p></li>
<li><p><strong>state</strong> (<em>StateObject</em>) – The state that stores schedule configuration for the workload</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ApplyHistoryBestOrSample">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">ApplyHistoryBestOrSample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">records</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sample_simple_workloads</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cost_model_file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_measure</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ApplyHistoryBestOrSample" title="永久链接至目标">¶</a></dt>
<dd><p>Apply the history best config, or sample a valid schedule if no config is found.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>records</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>iterator of</em><em> (</em><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.measure.MeasureInput"><em>auto_scheduler.measure.MeasureInput</em></a><em>,                                  </em><a class="reference internal" href="#tvm.auto_scheduler.MeasureResult" title="tvm.auto_scheduler.measure.MeasureResult"><em>auto_scheduler.measure.MeasureResult</em></a><em>)</em>) – Collection of tuning records.
If is str, then it should be the filename of a records log file.
Each row of this file is an encoded record pair. Otherwise, it is an iterator.</p></li>
<li><p><strong>sample_simple_workloads</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – When False, sampling will not apply to simple workloads (w/o reduction).</p></li>
<li><p><strong>cost_model_file</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The filename of the pre-trained XGBoost cost model. If not present, then random
model will be used.</p></li>
<li><p><strong>num_measure</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Meausre the top-N rank of sampled schedules on the device. The default -1 means
no measurement and simply return the top-1 schedule ranked by the cost model.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.ApplyHistoryBestOrSample.query" title="tvm.auto_scheduler.ApplyHistoryBestOrSample.query"><code class="xref py py-obj docutils literal notranslate"><span class="pre">query</span></code></a>(target, workload_key, has_complex_op, …)</p></td>
<td><p>Query the context to get the specific config for a workload.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.ApplyHistoryBestOrSample.query">
<span class="sig-name descname"><span class="pre">query</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">has_complex_op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.ApplyHistoryBestOrSample.query" title="永久链接至目标">¶</a></dt>
<dd><p>Query the context to get the specific config for a workload.
If this function cannot find the result inside this context, it will query the result
from the upper contexts.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>Target</em></a>) – The current target</p></li>
<li><p><strong>workload_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The workload key</p></li>
<li><p><strong>has_complex_op</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether this workload has at least one complex op.</p></li>
<li><p><strong>dag</strong> (<a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG" title="tvm.auto_scheduler.ComputeDAG"><em>ComputeDAG</em></a>) – The ComputeDAG of the workload.</p></li>
<li><p><strong>func_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The function name of this workload.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>state</strong> – The state that stores schedule configuration for the workload</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>StateObject</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.MeasureInput">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">MeasureInput</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.MeasureInput" title="永久链接至目标">¶</a></dt>
<dd><p>保存一次测量的输入数据</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>task</strong> (<a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a>) – The SearchTask of this measurement.</p></li>
<li><p><strong>state</strong> (<em>Union</em><em>[</em><em>State</em><em>, </em><em>StateObject</em><em>]</em>) – The State to be measured.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput.serialize" title="tvm.auto_scheduler.MeasureInput.serialize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">serialize</span></code></a>()</p></td>
<td><p>Custom serialization to workaround MeasureInput not exposing all its members to the TVM ffi interface.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.MeasureInput.serialize">
<span class="sig-name descname"><span class="pre">serialize</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.MeasureInput.serialize" title="永久链接至目标">¶</a></dt>
<dd><p>Custom serialization to workaround MeasureInput not exposing all its
members to the TVM ffi interface.</p>
<p>Note that we do not implement __getstate__ as it does not seem to work
with initialization of the workload registry (maybe because of
initialization order?).</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.MeasureResult">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">MeasureResult</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">costs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">error_no</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">error_msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">all_cost</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timestamp</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.MeasureResult" title="永久链接至目标">¶</a></dt>
<dd><p>保存一次测量的结果</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>costs</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>]</em>) – The time costs of execution.</p></li>
<li><p><strong>error_no</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The error code.</p></li>
<li><p><strong>error_msg</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The error message if there is any error.</p></li>
<li><p><strong>all_cost</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The time cost of build and run.</p></li>
<li><p><strong>timestamp</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – The time stamps of this measurement.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.LocalBuilder">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">LocalBuilder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_parallel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">build_func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.LocalBuilder" title="永久链接至目标">¶</a></dt>
<dd><p>LocalBuilder 使用本地 CPU 核心来构建并行程序。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>timeout</strong> (<em>int = 15</em>) – The timeout limit (in second) for each build thread.
This is used in a wrapper of the multiprocessing.Process.join().</p></li>
<li><p><strong>n_parallel</strong> (<em>int = multiprocessing.cpu_count</em><em>(</em><em>)</em>) – Number of threads used to build in parallel.</p></li>
<li><p><strong>build_func</strong> (<em>callable</em><em> or </em><em>str = &quot;default&quot;</em>) – If is ‘default’, use default build function
If is ‘ndk’, use function for android ndk
If is callable, use it as custom build function, expect lib_format field.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.LocalRunner">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">LocalRunner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">number</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">repeat</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_repeat_ms</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cooldown_interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enable_cpu_cache_flush</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.LocalRunner" title="永久链接至目标">¶</a></dt>
<dd><p>使用本地 CPU/GPU 测量程序消耗时间的 LocalRunner</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>timeout</strong> (<em>int = 10</em>) – The timeout limit (in second) for each run.
This is used in a wrapper of the multiprocessing.Process.join().</p></li>
<li><p><strong>number</strong> (<em>int = 3</em>) – The number of times to run the generated code for taking average.
We call these runs as one <cite>repeat</cite> of measurement.</p></li>
<li><p><strong>repeat</strong> (<em>int = 1</em>) – The number of times to repeat the measurement.
In total, the generated code will be run (1 + number x repeat) times,
where the first “1” is warm up and will be discarded.
The returned result contains <cite>repeat</cite> costs,
each of which is an average of <cite>number</cite> costs.</p></li>
<li><p><strong>min_repeat_ms</strong> (<em>int = 100</em>) – The minimum duration of one <cite>repeat</cite> in milliseconds.
By default, one <cite>repeat</cite> contains <cite>number</cite> runs. If this parameter is set,
the parameters <cite>number</cite> will be dynamically adjusted to meet the
minimum duration requirement of one <cite>repeat</cite>.
i.e., When the run time of one <cite>repeat</cite> falls below this time, the <cite>number</cite> parameter
will be automatically increased.</p></li>
<li><p><strong>cooldown_interval</strong> (<em>float = 0.0</em>) – The cool down interval between two measurements in seconds.</p></li>
<li><p><strong>enable_cpu_cache_flush</strong> (<em>bool = False</em>) – Whether to flush cache on CPU between repeated measurements.
Flushing cache can make the measured latency of one operator closer to
its actual latency during end-to-end inference.
To make this option effective, the argument <cite>number</cite> should also be set to 1.
This is only has effect on CPU task.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RPCRunner">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">RPCRunner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">host</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">priority</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_parallel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">number</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">repeat</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_repeat_ms</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cooldown_interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enable_cpu_cache_flush</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RPCRunner" title="永久链接至目标">¶</a></dt>
<dd><p>RPCRunner that uses RPC call to measures the time cost of programs on remote devices.
Or sometime we may need to use RPC even in local running to insulate the thread environment.
(e.g. running CUDA programs)</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The key of the device registered in the RPC tracker.</p></li>
<li><p><strong>host</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The host address of the RPC Tracker.</p></li>
<li><p><strong>port</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The port of RPC Tracker.</p></li>
<li><p><strong>priority</strong> (<em>int = 1</em>) – The priority of this run request, larger is more prior.</p></li>
<li><p><strong>n_parallel</strong> (<em>int = 1</em>) – The number of tasks run in parallel.</p></li>
<li><p><strong>timeout</strong> (<em>int = 10</em>) – The timeout limit (in second) for each run.
This is used in a wrapper of the multiprocessing.Process.join().</p></li>
<li><p><strong>number</strong> (<em>int = 3</em>) – The number of times to run the generated code for taking average.
We call these runs as one <cite>repeat</cite> of measurement.</p></li>
<li><p><strong>repeat</strong> (<em>int = 1</em>) – The number of times to repeat the measurement.
In total, the generated code will be run (1 + number x repeat) times,
where the first “1” is warm up and will be discarded.
The returned result contains <cite>repeat</cite> costs,
each of which is an average of <cite>number</cite> costs.</p></li>
<li><p><strong>min_repeat_ms</strong> (<em>int = 100</em>) – The minimum duration of one <cite>repeat</cite> in milliseconds.
By default, one <cite>repeat</cite> contains <cite>number</cite> runs. If this parameter is set,
the parameters <cite>number</cite> will be dynamically adjusted to meet the
minimum duration requirement of one <cite>repeat</cite>.
i.e., When the run time of one <cite>repeat</cite> falls below this time, the <cite>number</cite> parameter
will be automatically increased.</p></li>
<li><p><strong>cooldown_interval</strong> (<em>float = 0.0</em>) – The cool down interval between two measurements in seconds.</p></li>
<li><p><strong>enable_cpu_cache_flush</strong> (<em>bool = False</em>) – Whether to flush cache on CPU between repeated measurements.
Flushing cache can make the measured latency of one operator closer to
its actual latency during end-to-end inference.
To make this option effective, the argument <cite>number</cite> should also be set to 1.
This is only has effect on CPU task.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.LocalRPCMeasureContext">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">LocalRPCMeasureContext</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">priority</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_parallel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">number</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">repeat</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_repeat_ms</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cooldown_interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enable_cpu_cache_flush</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.LocalRPCMeasureContext" title="永久链接至目标">¶</a></dt>
<dd><p>A context wrapper for running RPCRunner locally.
This will launch a local RPC Tracker and local RPC Server.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>priority</strong> (<em>int = 1</em>) – The priority of this run request, larger is more prior.</p></li>
<li><p><strong>n_parallel</strong> (<em>int = 1</em>) – The number of tasks run in parallel.</p></li>
<li><p><strong>timeout</strong> (<em>int = 10</em>) – The timeout limit (in second) for each run.
This is used in a wrapper of the multiprocessing.Process.join().</p></li>
<li><p><strong>number</strong> (<em>int = 3</em>) – The number of times to run the generated code for taking average.
We call these runs as one <cite>repeat</cite> of measurement.</p></li>
<li><p><strong>repeat</strong> (<em>int = 1</em>) – The number of times to repeat the measurement.
In total, the generated code will be run (1 + number x repeat) times,
where the first “1” is warm up and will be discarded.
The returned result contains <cite>repeat</cite> costs,
each of which is an average of <cite>number</cite> costs.</p></li>
<li><p><strong>min_repeat_ms</strong> (<em>int = 0</em>) – The minimum duration of one <cite>repeat</cite> in milliseconds.
By default, one <cite>repeat</cite> contains <cite>number</cite> runs. If this parameter is set,
the parameters <cite>number</cite> will be dynamically adjusted to meet the
minimum duration requirement of one <cite>repeat</cite>.
i.e., When the run time of one <cite>repeat</cite> falls below this time, the <cite>number</cite> parameter
will be automatically increased.</p></li>
<li><p><strong>cooldown_interval</strong> (<em>float = 0.0</em>) – The cool down interval between two measurements in seconds.</p></li>
<li><p><strong>enable_cpu_cache_flush</strong> (<em>bool = False</em>) – Whether to flush cache on CPU between repeated measurements.
Flushing cache can make the measured latency of one operator closer to
its actual latency during end-to-end inference.
To make this option effective, the argument <cite>number</cite> should also be set to 1.
This is only has effect on CPU task.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.register_task_input_check_func">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">register_task_input_check_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">override</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.register_task_input_check_func" title="永久链接至目标">¶</a></dt>
<dd><p>注册一个检查输入缓冲区映射的函数</p>
<p>The input function should take a list of Tensor wich indicate the Input/output Tensor of a TVM
subgraph and return a Map from the input Tensor to its buffer name.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func_name</strong> (<em>Union</em><em>[</em><em>Function</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The check function that returns the compute declaration Tensors or its function name.</p></li>
<li><p><strong>f</strong> (<em>Optional</em><em>[</em><em>Function</em><em>]</em>) – The check function to be registered.</p></li>
<li><p><strong>override</strong> (<em>boolean = False</em>) – Whether to override existing entry.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@auto_scheduler.register_task_input_check_func</span>
<span class="k">def</span> <span class="nf">check_task_input_by_placeholder_name</span><span class="p">(</span><span class="n">args</span> <span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Tensor</span><span class="p">]):</span>
    <span class="n">tensor_input_map</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">:</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">op</span><span class="p">,</span> <span class="n">tvm</span><span class="o">.</span><span class="n">te</span><span class="o">.</span><span class="n">PlaceholderOp</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">op</span><span class="o">.</span><span class="n">name</span> <span class="o">!=</span> <span class="s2">&quot;placeholder&quot;</span><span class="p">:</span>
                <span class="n">tensor_input_map</span><span class="p">[</span><span class="n">arg</span><span class="p">]</span> <span class="o">=</span> <span class="n">arg</span><span class="o">.</span><span class="n">op</span><span class="o">.</span><span class="n">name</span>
    <span class="k">return</span> <span class="n">tensor_input_map</span>
</pre></div>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RecordToFile">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">RecordToFile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RecordToFile" title="永久链接至目标">¶</a></dt>
<dd><p>A measurement callback that writes measurement records into a file.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – File name for this callback to write log to.</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RecordReader">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">RecordReader</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RecordReader" title="永久链接至目标">¶</a></dt>
<dd><p>JSON 日志文件的读取器。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – File name for this reader to load log from.</p>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.RecordReader.check_workload_key" title="tvm.auto_scheduler.RecordReader.check_workload_key"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_workload_key</span></code></a>(inputs)</p></td>
<td><p>Check and throw warnings for records with old format workload key.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.RecordReader.read_lines" title="tvm.auto_scheduler.RecordReader.read_lines"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read_lines</span></code></a>([max_lines, skip_lines])</p></td>
<td><p>Read multiple lines from the log file.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RecordReader.check_workload_key">
<span class="sig-name descname"><span class="pre">check_workload_key</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RecordReader.check_workload_key" title="永久链接至目标">¶</a></dt>
<dd><p>Check and throw warnings for records with old format workload key.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>inputs</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.MeasureInput"><em>MeasureInput</em></a><em>]</em>) – The measure inputs to be checked.</p>
</dd>
</dl>
<p class="rubric">提示</p>
<p>This checker could be deprecated in the future.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.RecordReader.read_lines">
<span class="sig-name descname"><span class="pre">read_lines</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">max_lines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">skip_lines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.RecordReader.read_lines" title="永久链接至目标">¶</a></dt>
<dd><p>Read multiple lines from the log file.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>max_lines</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – The maximum number of lines. None to read all lines.</p></li>
<li><p><strong>skip_lines</strong> (<em>int = 0</em>) – Skip the first n lines.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>inputs</strong> (<em>List[auto_scheduler.measure.MeasureInput]</em>) – The MeasureInputs loaded from the log file.</p></li>
<li><p><strong>results</strong> (<em>List[auto_scheduler.measure.MeasureResult]</em>) – The MeasureResults loaded from the log file.</p></li>
</ul>
</p>
</dd>
</dl>
<p class="rubric">提示</p>
<p>Some unimportant and expensive fields in the returned MeasureInput are not deserialized
for faster read speed (e.g. input.task.compute_dag, input.state.stages).
If you want to use them, you can call the <code class="code docutils literal notranslate"><span class="pre">recover_measure_input</span></code> below
to rebuild these fields.</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.load_best_record">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">load_best_record</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_compatible</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.load_best_record" title="永久链接至目标">¶</a></dt>
<dd><p>Return the best measurement pair form a log file. This may return none results if
there is no legal measure pair with the specified workload_key/target found from the log file.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – File name to load log from.</p></li>
<li><p><strong>workload_key</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The workload key of the compute declaration.
With <cite>None</cite>, this returns the best measure pair of all workloads.</p></li>
<li><p><strong>target</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>]</em>) – The target device.
With <cite>None</cite>, this returns the best measure pair of all target devices.</p></li>
<li><p><strong>include_compatible</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – When set to True, all compatible records in the log file will be considered.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>input</strong> (<em>auto_scheduler.measure.MeasureInput</em>) – The best State’s MeasureInput from this log fine.</p></li>
<li><p><strong>result</strong> (<em>auto_scheduler.measure.MeasureResult</em>) – The best State’s MeasureResult from this log fine.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.load_records">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">load_records</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.load_records" title="永久链接至目标">¶</a></dt>
<dd><p>Load measurement records from a file.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – File name to load log from.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>logs</strong></p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="#tvm.auto_scheduler.MeasureInput" title="tvm.auto_scheduler.measure.MeasureInput">auto_scheduler.measure.MeasureInput</a>, <a class="reference internal" href="#tvm.auto_scheduler.MeasureResult" title="tvm.auto_scheduler.measure.MeasureResult">auto_scheduler.measure.MeasureResult</a>]</p>
</dd>
</dl>
<p class="rubric">提示</p>
<p>Some unimportant and expensive fields in the returned MeasureInput are not deserialized
for faster read speed (e.g., input.task.compute_dag, input.state.stages).
If you want to use them, you can call the <code class="code docutils literal notranslate"><span class="pre">recover_measure_input</span></code> below
to rebuild these fields.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.save_records">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">save_records</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">results</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.save_records" title="永久链接至目标">¶</a></dt>
<dd><p>Append measure records to file.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – File name to write log to.</p></li>
<li><p><strong>inputs</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>MeasureInputs</em><em>]</em>) – The MeasureInputs to be written.</p></li>
<li><p><strong>results</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>MeasureResults</em><em>]</em>) – The MeasureResults to be written.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.extract_tasks">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">extract_tasks</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">params</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hardware_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_simple_tasks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dump_workload_to_dag_log</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">opt_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.extract_tasks" title="永久链接至目标">¶</a></dt>
<dd><p>Extract tuning tasks from a relay program.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em><em> or </em><em>relay.function.Function</em>) – The module or function to tune</p></li>
<li><p><strong>params</strong> (<em>dict of str to numpy array</em>) – The associated parameters of the program</p></li>
<li><p><strong>target</strong> (<em>Union</em><em>[</em><a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The compilation target</p></li>
<li><p><strong>target_host</strong> (<em>Optional</em><em>[</em><em>Union</em><em>[</em><a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em><em>]</em>) – The host compilation target</p></li>
<li><p><strong>hardware_params</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.HardwareParams" title="tvm.auto_scheduler.HardwareParams"><em>HardwareParams</em></a><em>]</em>) – Hardware parameters used for the search tasks</p></li>
<li><p><strong>include_simple_tasks</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether to extract simple tasks that do not include complicated ops.</p></li>
<li><p><strong>dump_workload_to_dag_log</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – A file to dump an association between the workload keys and the actual DAG</p></li>
<li><p><strong>opt_level</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – The optimization level of the task extractions.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>tasks</strong> (<em>List[SearchTask]</em>) – The tasks in this network</p></li>
<li><p><strong>weights</strong> (<em>List[int]</em>) – The weight (i.e. the number of appearance) of extracted tasks</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.remove_index_check">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">remove_index_check</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tensor</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.remove_index_check" title="永久链接至目标">¶</a></dt>
<dd><p>Remove the safety check in the indexing function for a tensor.
This is done by monkey patching its indexing function.
After removing the check, we are allowed to create a
temporary wrong IR and fix it later in other places.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>tensor</strong> (<a class="reference internal" href="te.html#tvm.te.Tensor" title="tvm.te.Tensor"><em>Tensor</em></a>) – The tensor to remove index check.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.rewrite_compute_body">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">rewrite_compute_body</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">compute_tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">new_layout</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.rewrite_compute_body" title="永久链接至目标">¶</a></dt>
<dd><p>Rewrite the body of a ComputeOp according to a new layout of a placeholder</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.is_auto_scheduler_enabled">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">is_auto_scheduler_enabled</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.is_auto_scheduler_enabled" title="永久链接至目标">¶</a></dt>
<dd><p>Return whether the auto-scheduler is enabled.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>enabled</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether the auto-scheduler is enabled</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SearchTask">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">SearchTask</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compute_dag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workload_key</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hardware_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout_rewrite_option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">task_inputs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">task_inputs_overwrite</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">task_inputs_save_to_file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">desc</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SearchTask" title="永久链接至目标">¶</a></dt>
<dd><p>The computation information and hardware parameters for a schedule search task.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>Union</em><em>[</em><em>Function</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The function that returns the compute declaration Tensors.
Can be the a function or the function name.</p></li>
<li><p><strong>args</strong> (<em>Union</em><em>[</em><em>Tuple</em><em>[</em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>, </em><em>...</em><em>]</em><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>]</em>) – The args of the function.</p></li>
<li><p><strong>compute_dag</strong> (<a class="reference internal" href="#tvm.auto_scheduler.ComputeDAG" title="tvm.auto_scheduler.ComputeDAG"><em>ComputeDAG</em></a>) – The ComputeDAG for the corresponding compute declaration.</p></li>
<li><p><strong>workload_key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The workload key for the corresponding compute declaration.</p></li>
<li><p><strong>target</strong> (<a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a>) – The target device of this search task.</p></li>
<li><p><strong>target_host</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>]</em>) – The target host device of this search task.</p></li>
<li><p><strong>hardware_params</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.HardwareParams" title="tvm.auto_scheduler.HardwareParams"><em>HardwareParams</em></a><em>]</em>) – Hardware parameters used in this search task.</p></li>
<li><p><strong>layout_rewrite_option</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.LayoutRewriteOption" title="tvm.auto_scheduler.LayoutRewriteOption"><em>LayoutRewriteOption</em></a><em>]</em>) – The layout rewrite option used for measuring programs. If None, the default value will be
set depending on the specified target.
Auto_scheduler will find a better schedule for the specified layout rewrite option.
The NO_REWRITE and INSERT_TRANSFORM_STAGE are expected to be used when tuning a standalone
op, and the REWRITE_FOR_PRE_TRANSFORMED is expected to be used when tuning ops inside a
network.</p></li>
<li><p><strong>task_inputs</strong> (<em>Union</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="ndarray.html#tvm.nd.NDArray" title="tvm.nd.NDArray"><em>tvm.nd.NDArray</em></a><em>]</em><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em><em>]</em>) – A dict maps the input names to input tensors or a list of input names.
Some special Tensor used as inputs in program measuring. Usually we do not need to care
about it, but for special workloads like Sparse computation the Sparse Tensor input are
meaningful that we cannot use random input directly.</p></li>
<li><p><strong>task_inputs_overwrite</strong> (<em>bool = False</em>) – Whether to overwrite the data if a name has already in the global table.</p></li>
<li><p><strong>task_inputs_save_to_file</strong> (<em>bool = False</em>) – Whether to save the data to a local file as well. This can be reused to resume the last
tuning process.</p></li>
<li><p><strong>desc</strong> (<em>str = &quot;&quot;</em>) – The description string of this task.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># We support two ways to create a search task</span>

<span class="c1"># Way 1: create a task by a workload generation function.</span>
<span class="c1"># The `workload_func` is a function decorated by @auto_scheduler.register_workload</span>
<span class="n">task</span> <span class="o">=</span> <span class="n">SearchTask</span><span class="p">(</span><span class="n">func</span><span class="o">=</span><span class="n">workload_func</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="n">target</span><span class="p">)</span>

<span class="c1"># Way 2: create a task by a workload_key.</span>
<span class="c1"># The `workload_key` is a string, which can be either a hash key or a json-serialized</span>
<span class="c1"># tuple(func, args).</span>
<span class="n">task</span> <span class="o">=</span> <span class="n">SearchTask</span><span class="p">(</span><span class="n">workload_key</span><span class="o">=</span><span class="n">workload_key</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="n">target</span><span class="p">)</span>
</pre></div>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SearchTask.tune" title="tvm.auto_scheduler.SearchTask.tune"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tune</span></code></a>(tuning_options[, search_policy])</p></td>
<td><p>Run auto scheduling search for a task</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SearchTask.apply_best" title="tvm.auto_scheduler.SearchTask.apply_best"><code class="xref py py-obj docutils literal notranslate"><span class="pre">apply_best</span></code></a>(log_file[, include_compatible, …])</p></td>
<td><p>Apply the history best from a log file and return the schedule.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SearchTask.print_best" title="tvm.auto_scheduler.SearchTask.print_best"><code class="xref py py-obj docutils literal notranslate"><span class="pre">print_best</span></code></a>(log_file[, print_mode])</p></td>
<td><p>Print the best schedule as python schedule API code or CUDA source code.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SearchTask.tune">
<span class="sig-name descname"><span class="pre">tune</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tuning_options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">search_policy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SearchTask.tune" title="永久链接至目标">¶</a></dt>
<dd><p>Run auto scheduling search for a task</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tuning_options</strong> (<a class="reference internal" href="#tvm.auto_scheduler.TuningOptions" title="tvm.auto_scheduler.TuningOptions"><em>TuningOptions</em></a>) – Tuning and measurement options.</p></li>
<li><p><strong>search_policy</strong> (<em>Optional</em><em>[</em><em>SearchPolicy</em><em>]</em>) – The search policy to be used for schedule search.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SearchTask.apply_best">
<span class="sig-name descname"><span class="pre">apply_best</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">log_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_compatible</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout_rewrite_option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SearchTask.apply_best" title="永久链接至目标">¶</a></dt>
<dd><p>Apply the history best from a log file and return the schedule.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>log_file</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the log file.</p></li>
<li><p><strong>include_compatible</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – When set to True, all compatible records in the log file will be considered.</p></li>
<li><p><strong>layout_rewrite_option</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.LayoutRewriteOption" title="tvm.auto_scheduler.LayoutRewriteOption"><em>LayoutRewriteOption</em></a><em>]</em>) – The layout rewrite option.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p></p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>A <cite>te.Schedule</cite> and the a list of <cite>te.Tensor</cite> to be used in <cite>tvm.lower</cite> or <cite>tvm.build</cite>.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SearchTask.print_best">
<span class="sig-name descname"><span class="pre">print_best</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">log_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">print_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'schedule'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SearchTask.print_best" title="永久链接至目标">¶</a></dt>
<dd><p>Print the best schedule as python schedule API code or CUDA source code.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>log_file</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the log file</p></li>
<li><p><strong>print_mode</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – if “schedule”, print the best schedule as python schedule API code.
if “cuda”, print the best schedule as CUDA source code.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>code</strong> – The best schedule code in python API or CUDA source code</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.TuningOptions">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">TuningOptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num_measure_trials</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">early_stopping</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_measures_per_round</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">64</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">builder</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'local'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">runner</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'local'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">measure_callbacks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.TuningOptions" title="永久链接至目标">¶</a></dt>
<dd><p>This controls the options of performance tuning.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>num_measure_trials</strong> (<em>int = 0</em>) – The number of measurement trials.
The search policy measures <cite>num_measure_trials</cite> schedules in total and returns the best one
among them.
With <cite>num_measure_trials</cite> == 0, the policy will do the schedule search but won’t involve
measurement. This can be used to get a runnable schedule quickly without auto-tuning.</p></li>
<li><p><strong>early_stopping</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – Stop the tuning early if getting no improvement after n measurements.</p></li>
<li><p><strong>num_measures_per_round</strong> (<em>int = 64</em>) – The number of schedules to be measured at each search round.
The whole schedule search process will try a total number of <cite>num_measure_trials</cite> in several
rounds.</p></li>
<li><p><strong>verbose</strong> (<em>int = 1</em>) – Verbosity level. 0 for silent, 1 to output information during schedule search.</p></li>
<li><p><strong>builder</strong> (<em>Union</em><em>[</em><em>ProgramBuilder</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>] </em><em>= 'local'</em>) – ProgramBuilder which builds the program.</p></li>
<li><p><strong>runner</strong> (<em>Union</em><em>[</em><em>ProgramRunner</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>] </em><em>= 'local'</em>) – ProgramRunner which runs the program and measures time costs.</p></li>
<li><p><strong>measure_callbacks</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>MeasureCallback</em><em>]</em><em>]</em>) – Callback functions called after each measurement.
Candidates:
- auto_scheduler.RecordToFile</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.HardwareParams">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">HardwareParams</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num_cores</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vector_unit_bytes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cache_line_bytes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_shared_memory_per_block</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_local_memory_per_block</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_threads_per_block</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_vthread_extent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">warp_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.HardwareParams" title="永久链接至目标">¶</a></dt>
<dd><p>The parameters of target hardware used to guide the search policy.</p>
<p>When a parameter isn’t provided, it will instead use the
current machine’s default value if target is specified.
TODO(jcf94): This is considered to be merged with the new Target specification:
<a class="reference external" href="https://discuss.tvm.apache.org/t/rfc-tvm-target-specification/6844">https://discuss.tvm.apache.org/t/rfc-tvm-target-specification/6844</a>
:param num_cores: The number of device cores.
:type num_cores: int, optional
:param vector_unit_bytes: The width of vector units in bytes.
:type vector_unit_bytes: int, optional
:param cache_line_bytes: The size of cache line in bytes.
:type cache_line_bytes: int, optional
:param max_shared_memory_per_block: The max shared memory per block in bytes.
:type max_shared_memory_per_block: int, optional
:param max_local_memory_per_block: The max local memory per block in bytes.
:type max_local_memory_per_block: int, optional
:param max_threads_per_block: The max number of threads per block.
:type max_threads_per_block: int, optional
:param max_vthread_extent: The max vthread extent.
:type max_vthread_extent: int, optional
:param warp_size: The thread numbers of a warp.
:type warp_size: int, optional
:param target: The compilation target. Used to determine default values if provided.
:type target: str or Target, optional
:param target_host: The compilation target host. Used to determine default values if provided.
:type target_host: str or Target, optional</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.create_task">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">create_task</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hardware_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.create_task" title="永久链接至目标">¶</a></dt>
<dd><p>THIS API IS DEPRECATED.</p>
<p>Create a search task.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>Union</em><em>[</em><em>Function</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The function that returns the compute declaration Tensors.
Can be the a function or the function name.</p></li>
<li><p><strong>args</strong> (<em>Union</em><em>[</em><em>Tuple</em><em>[</em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>, </em><em>...</em><em>]</em><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>]</em>) – The args of the function.</p></li>
<li><p><strong>target</strong> (<em>Union</em><em>[</em><a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The target device of this search task.</p></li>
<li><p><strong>target_host</strong> (<em>Optional</em><em>[</em><em>Union</em><em>[</em><a class="reference internal" href="target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em><em>]</em>) – The target host device of this search task.</p></li>
<li><p><strong>hardware_params</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.HardwareParams" title="tvm.auto_scheduler.HardwareParams"><em>HardwareParams</em></a><em>]</em>) – Hardware parameters used in this search task.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>SearchTask</strong></p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>the created task</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.auto_schedule">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">auto_schedule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">search_policy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tuning_options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">auto_scheduler.TuningOptions(59641200)</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.auto_schedule" title="永久链接至目标">¶</a></dt>
<dd><p>THIS API IS DEPRECATED.</p>
<p>Run auto scheduling search for a task.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>task</strong> (<a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a>) – The SearchTask for the computation declaration.</p></li>
<li><p><strong>search_policy</strong> (<em>Optional</em><em>[</em><em>SearchPolicy</em><em>]</em>) – The search policy to be used for schedule search.</p></li>
<li><p><strong>tuning_options</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.TuningOptions" title="tvm.auto_scheduler.TuningOptions"><em>TuningOptions</em></a><em>]</em>) – Tuning and measurement options.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p></p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>A <cite>te.Schedule</cite> and the a list of <cite>te.Tensor</cite> to be used in <cite>tvm.lower</cite> or <cite>tvm.build</cite>.</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.EmptyPolicy">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">EmptyPolicy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">init_search_callbacks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.EmptyPolicy" title="永久链接至目标">¶</a></dt>
<dd><p>A simple example of the search policy which always returns
the initial naive schedule (state).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>task</strong> (<a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a>) – The SearchTask for the computation declaration.</p></li>
<li><p><strong>init_search_callbacks</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>SearchCallback</em><em>]</em><em>]</em>) – Callback functions called before the search process.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SketchPolicy">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">SketchPolicy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">task</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">program_cost_model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">auto_scheduler.RandomModel(59529432)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">init_search_callbacks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SketchPolicy" title="永久链接至目标">¶</a></dt>
<dd><p>The search policy that searches in a hierarchical search space defined by sketches.
The policy randomly samples programs from the space defined by sketches and use evolutionary
search to fine-tune them.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>task</strong> (<a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a>) – The SearchTask for the computation declaration.</p></li>
<li><p><strong>program_cost_model</strong> (<em>CostModel = RandomModel</em><em>(</em><em>)</em>) – The cost model to estimate the complete schedules.</p></li>
<li><p><strong>params</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>]</em>) – Parameters of the search policy.
See <cite>src/auto_scheduler/search_policy/sketch_search_policy.h</cite> for the definitions.
See <cite>DEFAULT_PARAMS</cite> below to find the default values.</p></li>
<li><p><strong>seed</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – Random seed.</p></li>
<li><p><strong>verbose</strong> (<em>int = 1</em>) – Verbosity level. 0 for silent, 1 to output information during schedule search.</p></li>
<li><p><strong>init_search_callbacks</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>SearchCallback</em><em>]</em><em>]</em>) – <p>Callback functions called before the search process, usually used to do extra
initializations.
Possible callbacks:</p>
<blockquote>
<div><ul>
<li><p>auto_scheduler.PreloadMeasuredStates</p></li>
<li><p>auto_scheduler.PreloadCustomSketchRule</p></li>
</ul>
</div></blockquote>
</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SketchPolicy.generate_sketches" title="tvm.auto_scheduler.SketchPolicy.generate_sketches"><code class="xref py py-obj docutils literal notranslate"><span class="pre">generate_sketches</span></code></a>([print_for_debug])</p></td>
<td><p>Generate the sketches.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SketchPolicy.sample_initial_population" title="tvm.auto_scheduler.SketchPolicy.sample_initial_population"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sample_initial_population</span></code></a>()</p></td>
<td><p>Sample initial population.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.SketchPolicy.evolutionary_search" title="tvm.auto_scheduler.SketchPolicy.evolutionary_search"><code class="xref py py-obj docutils literal notranslate"><span class="pre">evolutionary_search</span></code></a>(init_populations, out_size)</p></td>
<td><p>Perform evolutionary search.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SketchPolicy.generate_sketches">
<span class="sig-name descname"><span class="pre">generate_sketches</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_for_debug</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SketchPolicy.generate_sketches" title="永久链接至目标">¶</a></dt>
<dd><p>Generate the sketches.
This python interface is mainly used for debugging and testing.
The actual search is all done in c++.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>print_for_debug</strong> (<em>bool = False</em>) – Whether print out the sketches for debug.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>sketches</strong> – The generated sketches of this search task.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[State]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SketchPolicy.sample_initial_population">
<span class="sig-name descname"><span class="pre">sample_initial_population</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SketchPolicy.sample_initial_population" title="永久链接至目标">¶</a></dt>
<dd><p>Sample initial population.
This python interface is mainly used for debugging and testing.
The actual search is all done in c++.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>states</strong> – The sampled states</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[State]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.SketchPolicy.evolutionary_search">
<span class="sig-name descname"><span class="pre">evolutionary_search</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">init_populations</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_size</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.SketchPolicy.evolutionary_search" title="永久链接至目标">¶</a></dt>
<dd><p>Perform evolutionary search.
This python interface is mainly used for debugging and testing.
The actual search is all done in c++.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>init_populations</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>State</em><em>]</em>) – The initial population states</p></li>
<li><p><strong>out_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The size of generated states</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>states</strong> – The generated states</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[State]</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.PreloadMeasuredStates">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">PreloadMeasuredStates</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.PreloadMeasuredStates" title="永久链接至目标">¶</a></dt>
<dd><p>A SearchCallback to load measured states from the log file for a search policy.</p>
<dl class="simple">
<dt>This can resume the state of the search policy:</dt><dd><ul class="simple">
<li><p>Making sure an already measured state in former searches will never be measured again.</p></li>
<li><p>The history states can be used to speed up the search process(e.g. SketchPolicy uses
history states as starting point to perform Evolutionary Search).</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the record file.</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.PreloadCustomSketchRule">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">PreloadCustomSketchRule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">meet_condition_func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">apply_func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rule_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'CustomSketchRule'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.PreloadCustomSketchRule" title="永久链接至目标">¶</a></dt>
<dd><p>A SearchCallback for SketchSearchPolicy that allows users to add
custom sketch rule.</p>
<p class="rubric">提示</p>
<p>This is an advanced feature. Make sure you’re clear how it works and this should only be used
in SketchSearchPolicy.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>meet_condition_func</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable"><em>Callable</em></a>) – A function with <cite>(policy, state, stage_id) -&gt; int</cite>. Should return one of the result
enumeration.</p></li>
<li><p><strong>apply_func</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable"><em>Callable</em></a>) – A function with <cite>(policy, state, stage_id) -&gt; [[State, int], …]</cite>.</p></li>
<li><p><strong>rule_name</strong> (<em>str = &quot;CustomSketchRule&quot;</em>) – The name of this custom sketch rule.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.auto_scheduler.TaskScheduler">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">TaskScheduler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tasks</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">task_weights</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">objective_func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strategy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'gradient'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">load_model_file</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">load_log_file</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><span class="pre">float</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">beta</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><span class="pre">float</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gamma</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><span class="pre">float</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">backward_window_size</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><span class="pre">int</span></a></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callbacks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.TaskScheduler" title="永久链接至目标">¶</a></dt>
<dd><p>Allocate the time resources when tuning multiple tasks together.
This implements two strategies: “round-robin” and “gradient”.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tasks</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="#tvm.auto_scheduler.SearchTask" title="tvm.auto_scheduler.SearchTask"><em>SearchTask</em></a><em>]</em>) – All tasks to tune</p></li>
<li><p><strong>task_weights</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>]</em><em>]</em>) – The weights of tasks.
If provided, the task scheduler will set the objective function to
sum(weight[t] * latency[t]), where weight[t] is the weight of a task
and the lantecy[t] is the lantecy of the task.
If not provided, the task scheduer will assign equal weights to all
tasks (i.e., the objective function is sum(latency[t])).</p></li>
<li><p><strong>objective_func</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable"><em>Callable</em></a><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>] </em><em>-&gt; float</em><em>]</em><em>]</em>) – The objective function to be minimized.
The objective function accepts the current latencies of all tasks and returns the
objective.
If not provided, the objective is the weighted sum of the latencies of all tasks.</p></li>
<li><p><strong>strategy</strong> (<em>str = &quot;gradient&quot;</em>) – The scheduling strategy.
“round-robin”: Tune tasks in round robin order.
“gradient” : Tune tasks with gradient descent.</p></li>
<li><p><strong>load_model_file</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – Load pre-trained model from this file. If this is None, the cost model will
be trained from scratch.</p></li>
<li><p><strong>load_log_file</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – Load measurement records from this file. If it is not None, the status of the
task scheduler, search policies and cost models will be restored according to this file.</p></li>
<li><p><strong>verbose</strong> (<em>int = 1</em>) – The level of verbosity. 0 means silent.</p></li>
<li><p><strong>alpha</strong> (<em>float = 0.2</em>) – The parameter used for ‘gradient’ strategy</p></li>
<li><p><strong>beta</strong> (<em>float = 2</em>) – The parameter used for ‘gradient’ strategy</p></li>
<li><p><strong>backward_window_size</strong> (<em>int = 3</em>) – The parameter used for ‘gradient’ strategy</p></li>
<li><p><strong>callbacks</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>TaskSchedulerCallback</em><em>]</em><em>]</em>) – The task scheduler callbacks that will be called before and after tuning a task.
If None, PrintTableInfo and LogEstimatedLatency callback will be used.</p></li>
</ul>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.auto_scheduler.TaskScheduler.tune" title="tvm.auto_scheduler.TaskScheduler.tune"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tune</span></code></a>(tune_option[, search_policy, …])</p></td>
<td><p>Tune a batch of tasks together.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.auto_scheduler.TaskScheduler.tune">
<span class="sig-name descname"><span class="pre">tune</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tune_option</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">search_policy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">search_policy_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adapative_training</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">per_task_early_stopping</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.TaskScheduler.tune" title="永久链接至目标">¶</a></dt>
<dd><p>Tune a batch of tasks together.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tune_option</strong> (<a class="reference internal" href="#tvm.auto_scheduler.TuningOptions" title="tvm.auto_scheduler.TuningOptions"><em>TuningOptions</em></a>) – The tuning options applied to all tasks.</p></li>
<li><p><strong>search_policy</strong> (<em>: Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>SearchPolicy</em><em>]</em><em>] </em><em>= &quot;default&quot;</em>) – The list of search policies.
If it is str,
“default” for the default policy (SketchPolicy + XGBModel),
“sketch.xgb” for SketchPolicy + XGBModel,
“sketch.random” for SketchPolicy + RandomModel.</p></li>
<li><p><strong>search_policy_params</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>]</em>) – The parameters of the search policy</p></li>
<li><p><strong>adapative_training</strong> (<em>bool = False</em>) – Option used by XGBModel to reduce the model training frequency when there’re
too many logs.</p></li>
<li><p><strong>per_task_early_stopping</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>]</em>) – Stop tuning a task early if getting no improvement after n measurements.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.register_workload">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">register_workload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">override</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.register_workload" title="永久链接至目标">¶</a></dt>
<dd><p>Register a function that generates a certain workload.</p>
<p>The input function should take hashable and jsonable arguments
(int, float, tuple of int, tvm.tensor.Tensor, …) and return a list of tvm.tensor.Tensor.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func_name</strong> (<em>Union</em><em>[</em><em>Function</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The generation function that returns the compute declaration Tensors or its function name.</p></li>
<li><p><strong>f</strong> (<em>Optional</em><em>[</em><em>Function</em><em>]</em>) – The generation function to be registered.</p></li>
<li><p><strong>override</strong> (<em>boolean = False</em>) – Whether to override existing entry.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@auto_scheduler.register_workload</span>
<span class="k">def</span> <span class="nf">matmul</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">M</span><span class="p">,</span> <span class="n">K</span><span class="p">):</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">N</span><span class="p">,</span> <span class="n">K</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;A&#39;</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">placeholder</span><span class="p">((</span><span class="n">K</span><span class="p">,</span> <span class="n">M</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;B&#39;</span><span class="p">)</span>
    <span class="n">k</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">reduce_axis</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="n">K</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">)</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">te</span><span class="o">.</span><span class="n">compute</span><span class="p">((</span><span class="n">N</span><span class="p">,</span> <span class="n">M</span><span class="p">),</span> <span class="k">lambda</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">:</span> <span class="n">tvm</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">k</span><span class="p">]</span> <span class="o">*</span> <span class="n">B</span><span class="p">[</span><span class="n">k</span><span class="p">][</span><span class="n">j</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="p">[</span><span class="n">k</span><span class="p">]),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;C&#39;</span><span class="p">)</span>
    <span class="k">return</span> <span class="p">[</span><span class="n">A</span><span class="p">,</span> <span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.auto_scheduler.make_workload_key">
<span class="sig-prename descclassname"><span class="pre">tvm.auto_scheduler.</span></span><span class="sig-name descname"><span class="pre">make_workload_key</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.auto_scheduler.make_workload_key" title="永久链接至目标">¶</a></dt>
<dd><p>Make a workload key by function and arguments.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>Union</em><em>[</em><em>Function</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – The function that returns the compute declaration Tensors.
Can be the a function or the function name.</p></li>
<li><p><strong>args</strong> (<em>Args</em>) – The args of the function.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>workload_key</strong> – The workload key of the function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="rpc.html" class="btn btn-neutral float-right" title="tvm.rpc" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="autotvm.html" class="btn btn-neutral float-left" title="tvm.autotvm" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>